package _interview75;

/**
 * 11. 盛最多水的容器
 */
public class No11 {
    public int maxArea(int[] height) {
        int n = height.length;
        int left = 0, right = n - 1;
        int answer = (right - left) * Math.min(height[left], height[right]);
        while (left < right) {
            if (height[left] > height[right]) right--;
            else left++;
            answer = Math.max((right - left) * Math.min(height[left], height[right]), answer);
        }
        return answer;
    }
}
